package com.wan.nettyproject;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


import java.net.InetSocketAddress;
import java.util.concurrent.Executors;

/**
 * Created by Administrator on 2015/12/10.
 */
public class LoginActivity extends Activity {

    private String account;
    private String password;
    private ProgressDialog progressDialog;
    private android.widget.Button btn_login;
    private android.widget.EditText et_account;
    private android.widget.EditText et_password;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
        setContentView(R.layout.activity_login);

        initUI();
        btn_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                account = et_account.getText().toString();
                password = et_password.getText().toString();
                clickLogin();

            }
        });


    }
    public void clickLogin(){
        SocketManager.instance().connectMsgServer();
        MyApplication.user_name=account;
        Intent intent=new Intent(LoginActivity.this,MainActivity.class);
        intent.putExtra("from",account);
        intent.putExtra("to",password);
        startActivity(intent);
    }

    private void initUI() {
        this.et_password = (EditText) findViewById(R.id.et_password);
        this.et_account = (EditText) findViewById(R.id.et_account);
        btn_login = (Button) findViewById(R.id.btn_login);
    }
}
